$OpenBSD: patch-configure,v 1.55 2016/12/11 09:27:53 ajacoutot Exp $

lavu/random_seed: use arc4random() when available

--- configure.orig	Sat Dec 10 20:37:25 2016
+++ configure	Sat Dec 10 20:43:59 2016
@@ -1755,6 +1755,7 @@ MATH_FUNCS="
 SYSTEM_FUNCS="
     access
     aligned_malloc
+    arc4random
     clock_gettime
     closesocket
     CommandLineToArgvW
@@ -4308,7 +4309,7 @@ case $target_os in
     openbsd|bitrig)
         disable symver
         SHFLAGS='-shared'
-        SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBMAJOR).$(LIBMINOR)'
+        SLIB_INSTALL_NAME='$(SLIBNAME).$(LIBVERSION)'
         SLIB_INSTALL_LINKS=
         oss_indev_extralibs="-lossaudio"
         oss_outdev_extralibs="-lossaudio"
@@ -4672,7 +4673,7 @@ die_license_disabled version3 libvo_amrwbenc
 
 enabled version3 && { enabled gpl && enable gplv3 || enable lgplv3; }
 
-disabled optimizations || check_cflags -fomit-frame-pointer
+enabled x86_32 && check_cflags -fomit-frame-pointer
 
 enable_weak_pic() {
     disabled pic && return
@@ -5067,6 +5068,7 @@ check_func  ${malloc_prefix}memalign            && ena
 check_func  ${malloc_prefix}posix_memalign      && enable posix_memalign
 
 check_func  access
+check_func  arc4random
 check_func_headers time.h clock_gettime || { check_func_headers time.h clock_gettime -lrt && add_extralibs -lrt && LIBRT="-lrt"; }
 check_func  fcntl
 check_func  fork
@@ -5788,6 +5790,11 @@ if test $target_os = "haiku"; then
     disable posix_memalign
 fi
 
+
+if test $target_os = "openbsd"; then
+    enabled x86_32 && disable ebx_available
+fi
+
 enabled_all dxva2 dxva2api_cobj CoTaskMemFree &&
     prepend ffmpeg_libs $($ldflags_filter "-lole32" "-luser32") &&
     enable dxva2_lib
@@ -6220,8 +6227,8 @@ pkgconfig_generate(){
     comment=$2
     version=$3
     libs=$4
-    requires=$(map 'lib_version $v' $(eval echo \$${name#lib}_deps))
-    requires=${requires%, }
+    requires=$5
+    linkflags=$6
     enabled ${name#lib} || return 0
     mkdir -p $name
     cat <<EOF > $name/$name${build_suffix}.pc
@@ -6236,7 +6243,7 @@ Version: $version
 Requires: $(enabled shared || echo $requires)
 Requires.private: $(enabled shared && echo $requires)
 Conflicts:
-Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs)
+Libs: -L\${libdir} $(enabled rpath && echo "-Wl,-rpath,\${libdir}") -l${shortname} $(enabled shared || echo $libs) $linkflags
 Libs.private: $(enabled shared && echo $libs)
 Cflags: -I\${includedir}
 EOF
@@ -6260,12 +6267,12 @@ Cflags: -I\${includedir}
 EOF
 }
 
-pkgconfig_generate libavutil     "FFmpeg utility library"               "$LIBAVUTIL_VERSION"     "$LIBRT $LIBM"
-pkgconfig_generate libavcodec    "FFmpeg codec library"                 "$LIBAVCODEC_VERSION"    "$extralibs"
-pkgconfig_generate libavformat   "FFmpeg container format library"      "$LIBAVFORMAT_VERSION"   "$extralibs"
-pkgconfig_generate libavdevice   "FFmpeg device handling library"       "$LIBAVDEVICE_VERSION"   "$extralibs"
-pkgconfig_generate libavfilter   "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION"   "$extralibs"
-pkgconfig_generate libpostproc   "FFmpeg postprocessing library"        "$LIBPOSTPROC_VERSION"   ""
-pkgconfig_generate libavresample "Libav audio resampling library"       "$LIBAVRESAMPLE_VERSION" "$LIBM"
-pkgconfig_generate libswscale    "FFmpeg image rescaling library"       "$LIBSWSCALE_VERSION"    "$LIBM"
-pkgconfig_generate libswresample "FFmpeg audio resampling library"      "$LIBSWRESAMPLE_VERSION" "$LIBM $LIBSOXR"
+pkgconfig_generate libavutil     "FFmpeg utility library"               "$LIBAVUTIL_VERSION"     "$LIBavutil_EXTRALIBS"     "$LIBavutil_REQUIRES"     "$LIBavutil_LINKFLAGS"
+pkgconfig_generate libavcodec    "FFmpeg codec library"                 "$LIBAVCODEC_VERSION"    "$LIBavcodec_EXTRALIBS"    "$LIBavcodec_REQUIRES"    "$LIBavcodec_LINKFLAGS"
+pkgconfig_generate libavformat   "FFmpeg container format library"      "$LIBAVFORMAT_VERSION"   "$LIBavformat_EXTRALIBS"   "$LIBavformat_REQUIRES"   "$LIBavformat_LINKFLAGS"
+pkgconfig_generate libavdevice   "FFmpeg device handling library"       "$LIBAVDEVICE_VERSION"   "$LIBavdevice_EXTRALIBS"   "$LIBavdevice_REQUIRES"   "$LIBavdevice_LINKFLAGS"
+pkgconfig_generate libavfilter   "FFmpeg audio/video filtering library" "$LIBAVFILTER_VERSION"   "$LIBavfilter_EXTRALIBS"   "$LIBavfilter_REQUIRES"   "$LIBavfilter_LINKFLAGS"
+pkgconfig_generate libpostproc   "FFmpeg postprocessing library"        "$LIBPOSTPROC_VERSION"   "$LIBpostproc_EXTRALIBS"   "$LIBpostproc_REQUIRES"   "$LIBpostproc_LINKFLAGS"
+pkgconfig_generate libavresample "Libav audio resampling library"       "$LIBAVRESAMPLE_VERSION" "$LIBreavsample_EXTRALIBS" "$LIBavresample_REQUIRES" "$LIBavresample_LINKFLAGS"
+pkgconfig_generate libswscale    "FFmpeg image rescaling library"       "$LIBSWSCALE_VERSION"    "$LIBswscale_EXTRALIBS"    "$LIBswscale_REQUIRES"    "$LIBswscale_LINKFLAGS"
+pkgconfig_generate libswresample "FFmpeg audio rescaling library"       "$LIBSWRESAMPLE_VERSION" "$LIBswresample_EXTRALIBS" "$LIBswresample_REQUIRES" "$LIBswresample_LINKFLAGS"
